package com.hua.yuan.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.hua.yuan.base.Constents;
import com.hua.yuan.common.BaseActivity;
import com.hua.yuan.R;
import com.hua.yuan.manager.user.UserManagerModule;
import com.hua.yuan.util.ToastUtil;

import cm.hua.yuan.common.utils.PreferenceUtils;

/**
 * Created by huangyang on 2018/7/11.
 * 修改用户昵称的界面
 */

public class ChangeNickActivity extends BaseActivity implements View.OnClickListener {

    private ImageView backImage;
    private TextView titleView;

    private EditText userNickNameTv;
    private TextView cofChanged;

    private String nickName = "";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_nick);
        nickName = getIntent().getStringExtra("name");
        initView();
        initData();

    }

    private void initView() {
        backImage = findViewById(R.id.backImage);
        titleView = findViewById(R.id.titleView);
        userNickNameTv = findViewById(R.id.userNickNameTv);
        cofChanged = findViewById(R.id.cofChanged);
    }

    private void initData() {
        backImage.setOnClickListener(this);
        cofChanged.setOnClickListener(this);
        titleView.setText("修改昵称");
        userNickNameTv.setText(nickName);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.backImage:
                finish();
                break;
            case R.id.cofChanged:
                //确认修改
                String name = userNickNameTv.getText().toString().trim();
                Intent intent=new Intent();
                intent.putExtra(Constents.USER_NICK_NAME,name);
                setResult(UserManagerModule.BUSINESS_NICK_NAME,intent);
                finish();
                break;
        }
    }
}
